#include "stdafx.h"
#include "net/HTTPServer.hpp"
#include "net/HTTPServerConnection.hpp"
#include "net/HTTPServerConnection.hpp"

NET_NAMESPACE_BEGIN

CHTTPServer::CHTTPServer(CHTTPRequestHandlerFactory::Ptr pFactory, UInt16 portNumber, CHTTPServerParams::Ptr pParams)
	: CTCPServer(new CHTTPServerConnectionFactory(pParams, pFactory), portNumber, pParams),
	m_pFactory(pFactory)
{
}

CHTTPServer::CHTTPServer(CHTTPRequestHandlerFactory::Ptr pFactory, const CServerSocket& socket, CHTTPServerParams::Ptr pParams)
	: CTCPServer(new CHTTPServerConnectionFactory(pParams, pFactory), socket, pParams),
	m_pFactory(pFactory)
{
}

CHTTPServer::CHTTPServer(CHTTPRequestHandlerFactory::Ptr pFactory, CThreadPool& threadPool, const CServerSocket& socket, CHTTPServerParams::Ptr pParams)
	: CTCPServer(new CHTTPServerConnectionFactory(pParams, pFactory), threadPool, socket, pParams),
	m_pFactory(pFactory)
{
}

CHTTPServer::~CHTTPServer()
{
}

void CHTTPServer::stopAll(bool abortCurrent)
{
	stop();
	m_pFactory->serverStopped(this, abortCurrent);
}

NET_NAMESPACE_END
